11. Lab II: Build a Dog GraphQL API (Schema)

Lab II: Build a Dog GraphQL API

Let's build more onto our Dog GraphQL API we set up earlier, by adding an entity, GraphQL schema, basic CRUD repository, web service and controller.

Schema

Note that you can re-use your code from the REST API you built before for Step 1, as well as most of Step 3 depending on your implementation - just make sure you resolve the naming of packages and imports for your new project.

  • Step 1: Create an entity called Dog. The dog should have three attributes:
    • Name
    • Breed
    • Origin
  • Step 2: Create a GraphQL schema that matches the fields found in the Dog entity.
    • Add the following query operations:
    • findDogBreeds
    • findDogBreedById
    • findAllDogNames
    • Add the following mutators:
    • deleteDogBreed
    • updateDogName

Make sure to really think the query operations through here - would a user be able to use an otherwise broader query along with the specific fields they want to accomplish the same thing as some of these?

  • Step 3: Create a repository that extends CrudRepository for creating, reading, updating, and deleting Dog objects.